﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AUV5.Web.Service
{
    public partial class ServiceFavoriteCount : PageBaseService
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string serviceid = Request["serviceid"] ?? "";
            string secretkey = Request["secretkey"] ?? "";
            if (!isValidKey(secretkey, serviceid))
            {
                Response.Write("112");//密钥不正确 
                return;
            }

            if (Request["serviceid"]!=null)
            {
                Response.Write(BLL.FavoriteBLL.Instance.GetSFavCountByServiceId(serviceid));
            }
            else
            {
                Response.Write("111");//参数不正确 
            }
            
            
        }

        public bool isValidKey(string key,string serviceid)
        {
            if (secretkey_enable)
            {
                if (string.IsNullOrEmpty(key))
                {
                    return false;
                }
                else
                {
                    string secretkey = base.EncryptMD5(public_key + serviceid + DateTime.Now.ToString("yyyyMMdd")).Substring(6, 22);
                    return secretkey == key;
                }
            }
            else
            {
                return true;
            }
        }
    }
}